import {USER} from "../service/user.service";
import {Headers,RequestOptions} from "@angular/http";
/**
 * Created by johnson on 17/4/27.
 */
export class PageParam {
  public size?: number = 10;
  public page?: number = 0;
  public sort?: Array<string>;
}
export class ParamsModel {
  url:string;
  reqestData:any;
  context:any;
  options:RequestOptions;
  succCallback:any = (v,context)=> {
    console.log('succCallback')
  };
  failCallback:any = v=> {
    console.log('failCallback')
  };
  tokenExpireCallback:any = ()=> {
    console.log('tokenExpireCallback');
    this.USER.relogin();

  };
  errorCallback:any = v=> {
    console.log('errorCallback')
  };
  finallyCallback:any = ()=> {
    console.log('succCallback')
  };

  constructor(private USER:USER) {
    this.options = new RequestOptions({headers: new Headers({'Content-Type': 'application/json','Authorization':this.USER.getToken()})});
  }
  public getHeaders():any{
    return {'Authorization':this.USER.getToken()}
  }
  public setWwwFormContentType(){
    this.options = new RequestOptions({headers: new Headers({'Content-Type': 'application/x-www-form-urlencoded','Authorization':this.USER.getToken()})});
  }
}
